home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / ROM_Kernel_Manuals / Lib_examples / sample_stubs.asm < prev    next >
Encoding:
Assembly Source File  |  1992-08-20  |  2.3 KB  |  65 lines

  1. *******************************************************************************************
  2. * sample_stubs.asm
  3. *
  4. * Stubs match this .fd file:
  5. *
  6. *       ##base _SampleBase
  7. *       ##bias 30
  8. *       ##public
  9. *       Double(n1)(D0)
  10. *       AddThese(n1,n2)(D0/D1)
  11. *       ##end
  12. *
  13. * After assembling,
  14. *   JOIN sample_stubs.o sample_lvos.o AS sample.lib
  15. *
  16. * Apps LINK with LIBRARY sample.lib when calling sample.library functions
  17. *
  18. * If you put all of your stubs in one file, as shown here, then ALL of the stubs will be
  19. * linked into an application that references one stub.  For larger libraries, you should
  20. * place each stub in a separate assembler file, assemble them each separately, then join
  21. * all of the .o's together. That will allow each stub to be independently pulled into the
  22. * application that links with the .lib.
  23. *******************************************************************************************
  24.    INCLUDE  "exec/types.i"
  25.    INCLUDE  "exec/libraries.i"
  26.  
  27.           section code
  28.  
  29. *------ Caller declares and initializes SampleBase in their C code
  30.  
  31.             XREF        _SampleBase
  32.  
  33. *------ Must externally reference the _LVO labels defined in samplelib_lvos
  34.  
  35.             XREF        _LVODouble
  36.             XREF        _LVOAddThese
  37.  
  38. *------ Make C function stubs available to caller
  39.  
  40.             XDEF        _Double
  41.             XDEF        _AddThese
  42.  
  43. *------- These stubs move C args from stack to appropriate registers,
  44. *------- call the library function, and return result in d0
  45.  
  46. _Double:
  47.             MOVE.L      A6,-(SP)           ;Save register(s)
  48.             MOVE.L      8(SP),D0           ;Copy param to register
  49.             MOVE.L      _SampleBase,A6     ;Library base to A6
  50.             JSR         _LVODouble(A6)     ;Go to real routine
  51.             MOVE.L      (SP)+,A6           ;Restore register(s)
  52.             RTS
  53.  
  54. _AddThese:
  55.             MOVE.L      A6,-(SP)           ;Save register(s)
  56.             MOVEM.L     8(SP),D0/D1        ;Copy params to registers
  57.                                            ;8(SP)  goes into D0
  58.                                            ;12(SP) goes into D1
  59.             MOVE.L      _SampleBase,A6     ;Library base to A6
  60.             JSR         _LVOAddThese(A6)   ;Go to real routine
  61.             MOVE.L      (SP)+,A6           ;Restore register(s)
  62.             RTS
  63.  
  64.           END
  65.